﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace ProXMLParser
{
    class InputOutput
    {
        public InputOutput()
        {
        }
       
        internal string ReadFile(string AbsoluteFilePath, out bool ReadResult)
        {
            string FileData = "";

            FileStream fs = null;
            StreamReader sr = null;

            try
            {
                fs = new FileStream(AbsoluteFilePath, FileMode.Open, FileAccess.Read);
                sr = new StreamReader(fs);
                FileData = sr.ReadToEnd();
                sr.Close();
                fs.Close();

                ReadResult = true;

                return FileData;
            }
            catch (Exception ex)
            {
                try
                {
                    sr.Close();
                    fs.Close();
                }
                catch
                {
                    // Do nothing
                }

                ReadResult = false;

                throw ex;
            }
        }
    }
}
